<template>
	<view class="">
		<view class="top_title">
			米夸商城
		</view>
		<view class="top_btn">
			推荐榜
		</view>
		<view class="">

		</view>
		<view style="font-size: 24rpx;padding: 0 20rpx;color: #fff;text-align: center;margin-top: 40rpx;">
			{{catmessage.discribe}}
		</view>
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" :activeStyle="{
			fontSize:'24rpx',
			color:'#fff'
		}" lineColor="#fff" :inactiveStyle="{
			fontSize:'24rpx',
			color:'#fff'
		}" lineWidth="60"></u-tabs>

		<view class="items">

			<view class="item" v-for="(item,index) in cat" :key="item.id" @click="goto(item.id)">
				<view class="number">{{index+1}}</view>
				<view class="btn">
					<img src="/static/images/index/right-jiantou1.png" alt="" style="width: 30rpx;height: 30rpx;">
				</view>
				<view class="left">
					<img :src="item.thum_image" alt="">
				</view>
				<view class="right">
					<view style="font-size:24rpx;">{{item.name}}</view>
					<view style="color: #100f0f5e;font-size: 24rpx;">
						<!-- 官方首推入门 -->
					</view>
					<view style="font-size: 24rpx;">
						￥{{item.price}} 起
					</view>
				</view>
			</view>


		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '自行车畅销榜',
					id: 2
				}, {
					name: '周边热销榜',
					id: 3
				}],
				current: 0,
				cat: [],
				catmessage: {}
			}
		},
		async onLoad() {
			let cate = await this.$api.getgoodcate({
				status: '2'
			})
			this.cat = cate.data.goods.data
			this.catmessage = cate.data.category
		},
		methods: {
			goto(id) {
				uni.navigateTo({
					url: '/subPages/goodDetails/goodDetails?id=' + id
				})
			},
			async getcat(id) {
				let cate = await this.$api.getgoodcate({
					status: id
				})
				this.cat = cate.data.goods.data
				this.catmessage = cate.data.category
			},
			change(v) {
				this.getcat(v.id)
				// console.log(v);
				// this.current = v.index

			}
		}
	}
</script>

<style lang="scss">
	.items {
		padding-top: 30rpx;
		padding: 30rpx 20rpx 0;



		.btn {
			right: 30rpx;
			bottom: 30rpx;
			position: absolute;
			width: 55rpx;
			height: 55rpx;
			background-color: #3434dcc2;
			border-radius: 50%;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.item:nth-child(1) {
			.number {
				background-color: #9c9c35;
			}
		}

		.item:nth-child(2) {
			.number {
				background-color: #1510103d;
			}
		}

		.item:nth-child(3) {
			.number {
				background-color: #b3531491;
			}
		}

		.item {
			margin-top: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			display: flex;
			position: relative;

			.number {
				width: 50rpx;
				height: 50rpx;
				background-color: #ffff00a8;
				font-size: 30rpx;
				font-weight: 900;
				color: #fff;
				position: absolute;
				border-top-left-radius: 10rpx;
				border-bottom-right-radius: 10rpx;
				line-height: 50rpx;
				text-align: center;
			}



			.left {
				img {
					display: block;
					border-radius: 10rpx;
					width: 250rpx;
					height: 250rpx;
				}
			}

			.right {
				padding-top: 20rpx;
				padding-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-evenly;
			}
		}

	}

	page {
		padding-top: 40rpx;
		background-color: rgb(89, 137, 185);
		padding-bottom: 70rpx;
	}

	.top_title {
		font-size: 36rpx;
		text-align: center;
		font-weight: 700;
		color: #fff;
	}

	.top_btn {

		width: 200rpx;
		line-height: 50rpx;
		background-color: #fff;
		margin: 10rpx auto 30rpx;
		border-radius: 50rpx;
		// letter-spacing: 10rpx;
		text-align: center;
		color: rgb(89, 137, 185);
	}
</style>